package com.gec.system.exception;

import com.gec.system.util.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class GlobalException {
    @ExceptionHandler(Exception.class)
    @ResponseBody
    public Result error(Exception e){
        System.out.println("全局异常");
        e.printStackTrace();
        return Result.fail().message("执行了全局异常");
    }
    @ExceptionHandler(ArithmeticException.class)
    @ResponseBody
    public Result error(ArithmeticException e){
        System.out.println("算术异常");
        e.printStackTrace();
        return Result.fail().message("执行了算术异常");
    }
}
